Skip to content

feat: add sort toggle for RHS items (Created vs Updated)#1025

Open
rafaumeu wants to merge 1 commit into
mattermost:masterfrom
rafaumeu:feature/sort-rhs-242
Open

feat: add sort toggle for RHS items (Created vs Updated)#1025
rafaumeu wants to merge 1 commit into
mattermost:masterfrom
rafaumeu:feature/sort-rhs-242

Conversation

@rafaumeu

@rafaumeu rafaumeu commented Jun 16, 2026

Copy link
Copy Markdown

Summary

Adds a sort dropdown to the GitHub plugin RHS sidebar, allowing users to sort items by "Created" (default, existing behavior) or "Updated" date.

Resolves #242

Changes

  • Added a <select> dropdown in the RHS header with two options: "Sort: Created" and "Sort: Updated"
  • Default is "Created" which preserves existing behavior
  • Items are sorted client-side by created_at or updated_at field (descending)

Release Notes

Change Impact: 🟡 Medium

Reasoning: This introduces a new, user-facing right-sidebar sorting control and new client-side ordering logic (including updated_at fallback behavior), plus a fresh interactive dropdown component with keyboard/ARIA handling. While it doesn’t touch auth/session/data persistence, it can affect rendering and interaction correctness on the RHS across multiple sidebar states.

Regression Risk: Moderate — sorting and UI interaction changes are localized to the sidebar components, but date parsing/sorting and dropdown open/close/selection behavior are new paths that could regress in common usage.

QA Recommendation: Moderate manual QA recommended: validate default “Recently Created” and “Recently Updated” ordering for PR/review/unread/assignment contexts, confirm unread thread fallback when created_at is missing, and test dropdown mouse + keyboard navigation/focus/ARIA across light/dark themes. Skipping manual QA is not advised for the sorting dropdown and ordering behavior.
Generated by CodeRabbitAI

@rafaumeu rafaumeu requested a review from a team as a code owner June 16, 2026 22:14
@mattermost-build

Copy link
Copy Markdown
Contributor

Hello @rafaumeu,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds sidebar sorting by created or updated time, introduces a dedicated dropdown component, and wires a dev preview with webpack dev-server support. It also adds planning documents for the PR-fix workflow.

Changes

Sidebar sort feature

Layer / File(s) Summary
Sort state and dropdown contract
webapp/src/components/sidebar_right/sidebar_right.jsx, webapp/src/components/sidebar_right/sort_dropdown.jsx
Adds sidebar sort state and handler, imports the dropdown and theme helpers, and defines the dropdown props and defaults.
Item sorting and dropdown interactions
webapp/src/components/sidebar_right/sidebar_right.jsx, webapp/src/components/sidebar_right/sort_dropdown.jsx
Computes the sorted sidebar items, renders the sort control, and passes the sorted list to GithubItems.
Theme-based styling
webapp/src/components/sidebar_right/sidebar_right.jsx, webapp/src/components/sidebar_right/sort_dropdown.jsx
Replaces static sidebar styles with a theme-derived style function and adds dropdown layout and option styling.
Dev server wiring
webapp/public/index.html, webapp/src/dev.jsx, webapp/package.json, webapp/webpack.config.js
Adds the dev HTML shell, dev entry point, and webpack configuration for serving the sort preview in development.

Planning documents

Layer / File(s) Summary
Planning and context notes
.planning/mattermost-pr-fixes/AGENTS.md, .planning/mattermost-pr-fixes/CONTEXT.md, .planning/mattermost-pr-fixes/PLAN.md, .planning/mattermost-pr-fixes/SPEC.md
Adds the AGENTS, CONTEXT, PLAN, and SPEC documents with workflow notes, requirements, and checklists.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: avasconcelos114

Poem

A bunny found a sorty way,
To tidy PRs by night and day.
Updated now or newly born,
The sidebar hops in orderly form. 🐰

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes unrelated .planning docs and dev-server scaffolding beyond the #242 sorting feature. Split the planning documents and dev-only webpack/package changes into a separate PR unless they are required for the sort UI.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding a Created/Updated sort toggle for RHS items.
Linked Issues check ✅ Passed The PR implements the requested alternative RHS sorting, defaulting to Created and adding Updated as the client-side option.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@avasconcelos114 avasconcelos114 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello and thank you for the contribution! 🎉 :)

Before diving into reviewing the implementation I tested a build with your PR and noticed that the style of the select will need to be adjusted to match what the issue had it

Image

Refer to the comment in #242 (comment) to view the Figma prototype and let me know if you have any questions, thanks again!

@avasconcelos114 avasconcelos114 added 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester labels Jun 22, 2026
@mattermost-build

Copy link
Copy Markdown
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

@rafaumeu

rafaumeu commented Jul 5, 2026

Copy link
Copy Markdown
Author

Hi @avasconcelos114, I've addressed your review feedback in commit 394e874:

  1. Replaced native <select> with ReactSelect — now uses the plugin's getStyleForReactSelect(theme) which automatically adapts to Mattermost's dark/light themes, matching the Figma prototype's visual style.
  2. Theme-aware styles — converted the hardcoded const style to makeStyleFromTheme() so all inline styles respond to theme changes. The previous rgba(0, 0, 0, 0.2) border broke in dark theme.
  3. Accessibility — added aria-label='Sort items' to the dropdown.

The dropdown is isSearchable={false} (only 2 options) with menuPortalTarget=document.body to avoid clipping inside the RHS panel. Let me know if any further adjustments are needed!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@webapp/src/components/sidebar_right/sidebar_right.jsx`:
- Around line 223-235: The section header layout is missing a flex row, so the
new sort dropdown will stack under the title instead of sitting beside it.
Update the style returned by makeStyleFromTheme for sectionHeader in
sidebar_right.jsx to use a horizontal flex layout (while keeping the existing
padding), so the title link and sortDropdownContainer render on the same row.
- Around line 161-174: The unread-items sort logic in sidebar_right.jsx is using
created_at as the default for RHSStates.UNREADS, but those notification threads
only have updated_at, so the “Sort: Created” selection ends up comparing
undefined dates. Update the sorting branch around the sortedItems and
sortOptions/selectedSortOption logic to fall back to updated_at for unread
items, or hide/disable the Created option in this view so the selected label
matches the actual sort behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 55e1de93-0482-46c7-babd-2c1e4f0c3c26

📥 Commits

Reviewing files that changed from the base of the PR and between 5cd47fb and 394e874.

📒 Files selected for processing (1)
  • webapp/src/components/sidebar_right/sidebar_right.jsx

Comment thread webapp/src/components/sidebar_right/sidebar_right.jsx
Comment thread webapp/src/components/sidebar_right/sidebar_right.jsx Outdated
@rafaumeu

rafaumeu commented Jul 5, 2026

Copy link
Copy Markdown
Author

Addressed both CodeRabbit issues in 5d55c5d:

  1. sectionHeader flex layout (Major): Added display: flex, alignItems: center, justifyContent: space-between, and flexWrap: wrap to sectionHeader so the sort dropdown now renders beside the title.

  2. UNREADS sorting fallback (Minor): Notification threads don't expose created_at, so sorting by 'Created' compared undefined dates. Added a fallback to updated_at when created_at is missing.

@avasconcelos114

Copy link
Copy Markdown
Contributor

Hello again! Thank you for the revisions on the last batch of changes, I've confirmed that the sorting works great functionally :)

Though there is still quite a bit of discrepancy between the style in your implementation compared to the design created in Figma, but after this we should be good to officially QA and merge!

Implementation Design
image image

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@webapp/src/components/sidebar_right/sort_dropdown.jsx`:
- Around line 252-267: The option style object in sort_dropdown.jsx uses nested
:hover and :focus pseudo-selectors, but the React style prop ignores them.
Update the dropdown option rendering to use a styling approach that supports
interactive states, such as state-driven
onMouseEnter/onMouseLeave/onFocus/onBlur handling in the option component or a
CSS-in-JS solution already used in the codebase. Keep the existing option style
symbol and ensure the hover/focus visuals are applied through the component
logic rather than inline pseudo-selectors.
- Line 22: SortDropdown is using getStyle(theme) but the component is currently
rendered without a theme prop, so theme.centerChannelColor can be undefined at
render time. Update the SortDropdown usage so the parent passes the existing
theme value through, and verify the SortDropdown component and its PropTypes
definition stay aligned with the required theme prop.
- Around line 197-215: The trigger style in sort_dropdown’s dropdown
configuration removes keyboard focus visibility by setting outline to none, so
update the trigger styling to preserve a visible focus indicator. Adjust the
trigger style in the sort_dropdown component to use a theme-based focus ring or
state-driven focus style for the trigger button, and avoid relying on :focus in
inline styles so the focus indicator remains visible when the sort trigger is
keyboard-focused.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 955b08ec-3017-41b5-a5ec-86f540b7cb67

📥 Commits

Reviewing files that changed from the base of the PR and between 5d55c5d and eaa5155.

📒 Files selected for processing (2)
  • webapp/src/components/sidebar_right/sidebar_right.jsx
  • webapp/src/components/sidebar_right/sort_dropdown.jsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • webapp/src/components/sidebar_right/sidebar_right.jsx

Comment thread webapp/src/components/sidebar_right/sort_dropdown.jsx
Comment thread webapp/src/components/sidebar_right/sort_dropdown.jsx
Comment thread webapp/src/components/sidebar_right/sort_dropdown.jsx
@rafaumeu rafaumeu force-pushed the feature/sort-rhs-242 branch from c714531 to 1db479e Compare July 9, 2026 00:54

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
webapp/src/dev.jsx (1)

112-118: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Third dropdown shares state with the first.

The keyboard-navigation test dropdown (lines 112-118) reuses the same selected/setSelected state as the default dropdown (lines 50-56). Interacting with one updates the other, which may be confusing during manual testing. Consider a separate state variable if independent behavior is intended.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@webapp/src/dev.jsx` around lines 112 - 118, The keyboard-test SortDropdown is
sharing the same selected/setSelected state as the default SortDropdown, so
interactions are coupled. In dev.jsx, give the keyboard test dropdown its own
state variable and updater instead of reusing the existing selected state, and
wire that new state through the SortDropdown props so the two dropdowns behave
independently.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@webapp/src/components/sidebar_right/sort_dropdown.jsx`:
- Around line 50-52: The dropdown close handler in SortDropdown should clear
both the open flag and any lingering hover state. Update the handleClose method
in sort_dropdown.jsx so that hoveredOption is reset when isOpen is set to false,
preventing stale highlight state from surviving a dismiss-and-reopen cycle.
- Around line 107-110: The SortDropdown button is using a static accessible name
that hides the current selected sort value. Update the button in SortDropdown to
avoid a fixed aria-label like “Sort items”; either remove the aria-label so the
visible text from the button content is used, or make the label dynamic to
include the current selection from the sort state/value (e.g., the same value
shown in the button text).

In `@webapp/webpack.config.js`:
- Around line 25-31: HtmlWebpackPlugin is being added unconditionally in the
webpack.config.js plugins setup, so production bundling creates an unnecessary
index.html in dist. Update the plugins array in the webpack config to only
include HtmlWebpackPlugin when isDev is true, while keeping webpack.DefinePlugin
active for all builds.

---

Nitpick comments:
In `@webapp/src/dev.jsx`:
- Around line 112-118: The keyboard-test SortDropdown is sharing the same
selected/setSelected state as the default SortDropdown, so interactions are
coupled. In dev.jsx, give the keyboard test dropdown its own state variable and
updater instead of reusing the existing selected state, and wire that new state
through the SortDropdown props so the two dropdowns behave independently.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0a960729-af05-4d24-8d78-5ec4140c1da6

📥 Commits

Reviewing files that changed from the base of the PR and between c714531 and d3069ec.

⛔ Files ignored due to path filters (3)
  • webapp/package-lock.json is excluded by !**/package-lock.json
  • webapp/sort_dropdown_closed.png is excluded by !**/*.png
  • webapp/sort_dropdown_open.png is excluded by !**/*.png
📒 Files selected for processing (10)
  • .planning/mattermost-pr-fixes/AGENTS.md
  • .planning/mattermost-pr-fixes/CONTEXT.md
  • .planning/mattermost-pr-fixes/PLAN.md
  • .planning/mattermost-pr-fixes/SPEC.md
  • webapp/package.json
  • webapp/public/index.html
  • webapp/src/components/sidebar_right/sidebar_right.jsx
  • webapp/src/components/sidebar_right/sort_dropdown.jsx
  • webapp/src/dev.jsx
  • webapp/webpack.config.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • webapp/src/components/sidebar_right/sidebar_right.jsx

Comment thread webapp/src/components/sidebar_right/sort_dropdown.jsx
Comment thread webapp/src/components/sidebar_right/sort_dropdown.jsx
Comment thread webapp/webpack.config.js
@rafaumeu

rafaumeu commented Jul 9, 2026

Copy link
Copy Markdown
Author

Nitpick: webapp/src/dev.jsx — The keyboard-test SortDropdown shares state with the default SortDropdown.

✅ Addressed in commit 24ebe73 — the keyboard-test dropdown now uses its own selected2/setSelected2 state (already declared at line 20, just wasn't wired):

 <SortDropdown
-    value={selected}
-    onChange={setSelected}
+    value={selected2}
+    onChange={setSelected2}
     options={options}
     theme={mockTheme}
     ariaLabel={'Keyboard test'}
 />

Both dropdowns now operate independently.

Add a SortDropdown component to the RHS sidebar that allows users to
toggle sorting between 'Recently Created' and 'Recently Updated'.

- SortDropdown: custom accessible dropdown with theme support,
  keyboard navigation, and click-outside-to-close behavior
- SidebarRight: integrates SortDropdown, sorts items by selected
  criteria, falls back to updated_at for notification threads
  that lack created_at
- Uses makeStyleFromTheme for consistent theme-aware styling

Fixes mattermost#242
@rafaumeu rafaumeu force-pushed the feature/sort-rhs-242 branch from 24ebe73 to a0bb43e Compare July 9, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester Contributor Lifecycle/1:stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add alternative sorting functionality for RHS view

3 participants